﻿@using Pay.Token.Utils
@model PagedResult<product_dto>
@{
    var img_url = ViewBag.img_url;
    int userType = ViewBag.UserType;
    if (Model.rows.Count > 0) {
        foreach (var item in Model.rows) {
            <div class="item">
                <a href="/DistributionMall/ProductDetail?productId=@item.id" target="_blank">
                    <div class="itemBox">
                        <div class="img">
                            <img src="@(item.main_image_url)" />
                        </div>
                        <div class="box">
                            <p class="tit">@item.name</p>
                            <div class="mb20">
                                <p>
                                    @if (item.price > 0) {
                                        <em class="col-red fn20">￥</em>
                                        <span class="col-red fn32">@item.price.ToString("0.##")</span>
                                    }

                                    @if (item.activity_ex != null && item.price > 0 && item.activity_ex.activity_red_drill > 0) {
                                        <span class="col-red">+</span>
                                    }

                                    @if (item.activity_ex != null && item.activity_ex.activity_red_drill > 0) {
                                        <span class="col-red fn32">@item.activity_ex.activity_red_drill.ToString("0.######")</span> <em class="col-red fn20">红钻</em>
                                    }
                                </p>
                                <p style="white-space:nowrap;">
                                    <em class="col-red fn20">收益</em>
                                    <span class="col-red fn28 fontweight">
                                        @if (userType > 0) {
                                            @(DistributionHelper.GetProfitByLevel(item.distribution_price.GetValueOrDefault(0), (UserType)ViewBag.UserType).ToString("f2"))
                                        } else {
                                            @((item.distribution_price.GetValueOrDefault(0) * 0.1M).ToString("f2") + "～" + item.distribution_price.GetValueOrDefault(0).ToString("f2"))
                                        }
                                    </span>
                                </p>
                            </div>
                            @if (!(item.activity_ex != null && (item.activity_ex.activity_type == EActivityType.ProductMaker || item.activity_ex.activity_type == EActivityType.ProductOnlyRedDrill))
                                && item.price > 0) {
                                    <span class="ui-btn-share ui-btn-share-100 fxPro" href="javascript:void(0)" data-main_image_url="@(item.main_image_url)" data-price="@item.price.ToString("0.##")"
                                          data-red-drill="@((item.activity_ex != null ? item.activity_ex.activity_red_drill : 0).ToString("0.######"))"
                                          data-cost-price="@item.market_price" data-name="@(item.name.Length > 30 ? item.name.Substring(0, 30) : item.name)" data-id="@item.id">立即分享</span>
                             }
                        </div>
                    </div>
                </a>
            </div>
        }
    }
    <page total_pages="@Model.total_pages" rows="@Model.rows.Count()" total_result="@Model.total_result"></page>
}

